﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		BlogRoll.Builder.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 //   File:            BlogRoll.Builder.cs
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion
 
using System;
using Topics.Radical.Validation;

namespace Dexter.Domain.Model {
	public partial class BlogRoll {
		
		/// <summary>
		/// Creates a new instance of <see cref="BlogRoll"/>.
		/// </summary>
		/// <param name="name">The name of the Blog Roll.</param>
		/// <param name="link">The link.</param>
		/// <returns>A new instance of <see cref="BlogRoll"/></returns>
		/// <exception cref="ArgumentNullException"> If <paramref name="name"/> is <c>null</c>.</exception>
		/// <exception cref="ArgumentOutOfRangeException"> If <paramref name="name"/> is <c>empty</c>.</exception>
		/// <exception cref="ArgumentNullException"> If <paramref name="link"/> is <c>null</c>.</exception>
		public static BlogRoll CreateNewBlogRoll ( string name , Uri link ) {
			Ensure.That ( link )
				.Named ( "link" )
				.WithPreview ( ( v , e ) => Logger.Warn ( v.GetFullErrorMessage ( ) , e ) )
				.IsNotNull ( )
				.WithMessage ( "Invalid BlogRoll link format." );

			Ensure.That ( name )
				.Named ( "name" )
				.WithPreview ( ( v , e ) => Logger.Warn ( v.GetFullErrorMessage ( ) , e ) )
				.IsNotNullNorEmpty ( )
				.WithMessage ( "Invalid BlogRoll name." );

			return new BlogRoll ( name , link );
		}
	}
}
